package com.summer.controller;

import com.summer.R;
import com.summer.service.MsmService;
import com.summer.utils.RandomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/edumsm/msm")
@CrossOrigin
public class MsmController {
    @Autowired
    private MsmService msmService;
    @GetMapping("send/{phone}")
    public R sendMsm(@PathVariable String phone){
        String code = RandomUtil.getFourBitRandom();
        Map<String, Object> params=new HashMap<>();
        params.put("code",code);
       boolean isSend= msmService.send(params,phone);
       if (isSend){
        return  R.ok();
       }else {
           return R.error().message("发送短信失败");
       }

    }
}
